import axios from 'axios';

const API_URL = 'https://localhost:5005/api/menu';

export const getMenus = async () => {
  try {
    const response = await axios.get(API_URL);
    console.log('API响应数据:', response.data); // 调试原始响应
    // 确保返回数组且保留Children结构
    return Array.isArray(response.data) ? response.data : [];
  } catch (error) {
    console.error('菜单获取失败:', error);
    throw error;
  }
};